<?php
namespace Rainrock\Framework\Controller;



use Rainrock\Framework\kernel\core\Module;
use Rainrock\Framework\kernel\base\Request;

/**
*	需要登录就继承这个控制器和模块的验证的
*/
class AuthModeController extends AuthController{
	
	protected $modeInfo,$modenum,$mid = 0;
	
	public function backError($str)
	{
		if(Request::isajax())return $str;
		return MsgView::Error($str,'返回','javascript:js.back()');
	}
	
	/**
	*	验证的
	*/
	public function checkAccess()
	{
		$barr = parent::checkAccess();
		if($barr)return $barr;
		
		$num  	= Request::param('num');
		$group  = Request::get('group');
		$mid  	= Request::getint('mid');
		
		if(!$num || $mid < 0)return $this->backError('参数错误');
		if(!$group)$group = Module::getGroup($num);
		
		$mode = Module::get($num, $group);
		if(!$mode)return $this->backError(''.$num.'模块不存在');
		
		$this->mid  	= $mid;
		$this->modenum  = $num;
		$this->modeInfo = $mode;
	}
	
}